package menu

import (
	"gitee.com/yangguoliang001/go-gin-vue3/services/menuService"
	"github.com/gin-gonic/gin"
	"github.com/go-redis/redis/v7"
	"gorm.io/gorm"

	"go.uber.org/zap"
)

type Controller interface {
	QueryMenuList(c *gin.Context)
	QueryMenuItemDetail(c *gin.Context)
	EditMenu(c *gin.Context)
	UpdateMenuUsed(c *gin.Context)
	UpdateMenuSort(c *gin.Context)
	DeleteMenu(c *gin.Context)
	QueryMenuActionList(c *gin.Context)
	AddMenuAction(c *gin.Context)
	DeleteMenuAction(c *gin.Context)
}

type menuController struct {
	logger      *zap.Logger
	cache       *redis.Client
	menuService menuService.MenuServices
}

func New(logger *zap.Logger, db *gorm.DB, cache *redis.Client) Controller {
	return &menuController{
		logger:      logger,
		cache:       cache,
		menuService: menuService.New(logger, db, cache),
	}
}
